﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using S.Produce.Read.Api.Application.Commands.DeliveryCommands;

namespace S.Produce.Read.Api.Controllers
{
    /// <summary>
    /// 种母分娩控制器（读）
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DeliverysController : ControllerBase
    {
        private readonly IMediator mediator;

        /// <summary>
        /// 构造方式注入
        /// </summary>
        /// <param name="mediator"></param>
        public DeliverysController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 显示，查询，分页种母分娩信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetDelivery([FromQuery] DeliverySelectCommand command)
        {
            return Ok(await mediator.Send(command));
        }


                /// <summary>
        /// 显示所有分娩信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetAllDelivery([FromQuery] GetAllDeliveryCommands command)
        {
            return Ok(await mediator.Send(command));
        }

        /// <summary>
        /// 回填分娩信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> BackfillDelivery([FromQuery] DeliveryBackfillCommand command)
        {
            return Ok(await mediator.Send(command));
        }

        /// <summary>
        /// 根据耳号获取种母分娩信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> DeliveryEarsel([FromQuery]DeliveryEarselCommand command)
        {
            return Ok(await mediator.Send(command));
        }
    }
}
